wait_timeout = "60"
http_cmd = [
    {
        "cmd": 'AT+HTTPINIT=?',
        "match": 'AT\+HTTPINIT=\?\s{4}OK\s{2}',
    },
    {
        "cmd": 'AT+HTTPSSL?',
        "match": 'AT\+HTTPSSL\?\s{4}\+HTTPSSL: \d\s{4}OK\s{2}',
    },
    {
        "cmd": 'AT+HTTPSSL=?',
        "match": 'AT\+HTTPSSL=\?\s{4}\+HTTPSSL:\(0\-1\)\s{4}OK\s{2}',
    },
    {
        "cmd": 'AT+HTTPPARA?',
        "match": 'AT\+HTTPPARA\?\s{4}\+HTTPPARA:\s{2}(?:.|\n)*\s{4}OK\s{2}',
        "wait": b'OK',
        "timeout": wait_timeout
    },
    {
        "cmd": 'AT+HTTPPARA=?',
        "match": 'AT\+HTTPPARA=\?\s{4}\+HTTPPARA: "HTTPParamTag","HTTPParamValue"\s{4}OK\s{2}',
    },
    {
        "cmd": 'AT+HTTPDATA=?',
        "match": 'AT\+HTTPDATA=\?\s{4}\+HTTPDATA: \(0\-319488\),\(1000\-120000\)\s{4}OK\s{2}',
    },
    {
        "cmd": 'AT+HTTPACTION=?',
        "match": 'AT\+HTTPACTION=\?\s{4}\+HTTPACTION: \(0\-2\)\s{4}OK\s{2}',
    },
    {
        "cmd": 'AT+HTTPREAD=?',
        "match": 'AT\+HTTPREAD=\?\s{4}\+HTTPREAD: \(0\-319488\),\(1\-319488\)\s{4}OK\s{2}',
    },
    {
        "cmd": 'AT+HTTPHEAD=?',
        "match": 'AT\+HTTPHEAD=\?\s{4}OK\s{2}',
    },
    {
        "cmd": 'AT+HTTPTERM=?',
        "match": 'AT\+HTTPTERM=\?\s{4}OK\s{2}',
    },
    {
        "cmd": 'AT+SAPBR=3,1,"Contype","GPRS"',
        "match": 'AT\+SAPBR=3,1,"Contype","GPRS"\s{4}OK\s{2}',
    },
    {
        "cmd": 'AT+SAPBR=3,1,"APN",""',
        "match": 'AT\+SAPBR=3,1,"APN",""\s{4}OK\s{2}',
    },
    {
        "cmd": 'AT+SAPBR=1,1',
        "match": 'AT\+SAPBR=1,1\s{4}OK\s{2}',
        "wait": b'OK',
        "timeout": wait_timeout
    },
    {
        "cmd": 'AT+SAPBR=2,1',
        "match": 'AT\+SAPBR=2,1\s{4}\+SAPBR: \d,\d,"[\.\d]+"\s{4}OK\s{2}',
    },
    {
        "cmd": 'AT+HTTPINIT',
        "match": 'AT\+HTTPINIT\s{4}OK\s{2}',
    },
    {
        "cmd": 'AT+HTTPPARA="CID",1',
        "match": 'AT\+HTTPPARA="CID",1\s{4}OK\s{2}',
    },
    {
        "cmd": 'AT+HTTPPARA="URL","http://airtest.openluat.com:2900/?test1=1&test2=22&test3=333&test4=%E5%9B%9B%E5%9B%9B%E5%9B%9B%E5%9B%9B&test5=FiveFiveFiveFiveFive&test6=%E3%82%8D%E3%81%8F%E3%82%8D%E3%81%8F%E3%82%8D%E3%81%8F%E3%82%8D%E3%81%8F%E3%82%8D%E3%81%8F%E3%82%8D%E3%81%8F"',
        "match": 'AT\+HTTPPARA="URL","http://airtest.openluat.com:2900/\?test1=1&test2=22&test3=333&test4=%E5%9B%9B%E5%9B%9B%E5%9B%9B%E5%9B%9B&test5=FiveFiveFiveFiveFive&test6=%E3%82%8D%E3%81%8F%E3%82%8D%E3%81%8F%E3%82%8D%E3%81%8F%E3%82%8D%E3%81%8F%E3%82%8D%E3%81%8F%E3%82%8D%E3%81%8F"\s{4}OK\s{2}',
    },
    {
        "cmd": 'AT+HTTPACTION=0',
        "match": 'AT\+HTTPACTION=0\s{4}OK\s{4}\+HTTPACTION: 0,200,14\s{2}',
        "wait": b'+HTTPACTION:',
        "timeout": wait_timeout
    },
    {
        "cmd": 'AT+HTTPREAD=0,20',
        "match": 'AT\+HTTPREAD=0,20\s{4}\+HTTPREAD: 14\s{2}getTestSuccess\s{2}OK\s{2}',
        "wait": b'OK',
        "timeout": wait_timeout
    },
    {
        "cmd": 'AT+HTTPPARA="URL","http://airtest.openluat.com:2900/redirect301"',
        "match": 'AT\+HTTPPARA="URL","http://airtest\.openluat\.com:2900/redirect301"\s{4}OK\s{2}',
    },
    {
        "cmd": 'AT+HTTPPARA="REDIR","1"',
        "match": 'AT\+HTTPPARA="REDIR","1"\s{4}OK\s{2}',
    },
    {
        "cmd": 'AT+HTTPACTION=0',
        "match": 'AT\+HTTPACTION=0\s{4}OK\s{4}\+HTTPACTION: 0,200,108025\s{2}',
        "wait": b'+HTTPACTION:',
        "timeout": wait_timeout
    },
    {
        "cmd": 'AT+HTTPPARA="URL","http://airtest.openluat.com:2900/redirect302"',
        "match": 'AT\+HTTPPARA="URL","http://airtest\.openluat\.com:2900/redirect302"\s{4}OK\s{2}',
    },
    {
        "cmd": 'AT+HTTPACTION=0',
        "match": 'AT\+HTTPACTION=0\s{4}OK\s{4}\+HTTPACTION: 0,200,227\s{2}',
        "wait": b'+HTTPACTION:',
        "timeout": wait_timeout
    },
    {
        "cmd": 'AT+HTTPPARA="USER_DEFINED","Content-Type: text/plain"',
        "match": 'AT\+HTTPPARA="USER_DEFINED","Content\-Type: text/plain"\s{4}OK\s{2}',
    },
    {
        "cmd": 'AT+HTTPPARA="URL","http://airtest.openluat.com:2900"',
        "match": 'AT\+HTTPPARA="URL","http://airtest\.openluat\.com:2900"\s{4}OK\s{2}',
    },
    {
        "cmd": 'AT+HTTPDATA=8,100000',
        "match": 'AT\+HTTPDATA=8,100000\s{4}DOWNLOAD\s{2}',
    },
    {
        "cmd": 'PostTest',
        "match": '\s{2}OK\s{2}',
        "enter": False
    },
    {
        "cmd": 'AT+HTTPACTION=1',
        "match": 'AT\+HTTPACTION=1\s{4}OK\s{4}\+HTTPACTION: 1,200,15\s{2}',
        "wait": b'+HTTPACTION:',
        "timeout": wait_timeout
    },
    {
        "cmd": 'AT+HTTPREAD',
        "match": 'AT\+HTTPREAD\s{4}\+HTTPREAD: 15\s{2}postTestSuccess\s{2}OK\s{2}',
        "wait": b'OK',
        "timeout": wait_timeout
    },
    {
        "cmd": 'AT+HTTPPARA="URL","http://airtest.openluat.com:2900/calcPostDataLen"',
        "match": 'AT\+HTTPPARA="URL","http://airtest\.openluat\.com:2900/calcPostDataLen"\s{4}OK\s{2}',
    },
    {
        "cmd": 'AT+HTTPDATA=1024,100000',
        "match": 'AT\+HTTPDATA=1024,100000\s{4}DOWNLOAD\s{2}',
    },
    {
        "cmd": open("static/1024.txt").read(),
        "match": '\s{2}OK\s{2}',
        "enter": False
    },
    {
        "cmd": 'AT+HTTPACTION=1',
        "match": 'AT\+HTTPACTION=1\s{4}OK\s{4}\+HTTPACTION: 1,200,4\s{2}',
        "wait": b'+HTTPACTION:',
        "timeout": wait_timeout
    },
    {
        "cmd": 'AT+HTTPREAD',
        "match": 'AT\+HTTPREAD\s{4}\+HTTPREAD: 4\s{2}1024\s{2}OK\s{2}',
        "wait": b'OK',
        "timeout": wait_timeout
    },
    {
        "cmd": 'AT+HTTPPARA="URL","http://airtest.openluat.com:2900"',
        "match": 'AT\+HTTPPARA="URL","http://airtest\.openluat\.com:2900"\s{4}OK\s{2}',
    },
    {
        "cmd": 'AT+HTTPACTION=2',
        "match": 'AT\+HTTPACTION=2\s{4}OK\s{4}\+HTTPACTION: 2,200,0\s{2}',
        "wait": b'+HTTPACTION:',
        "timeout": wait_timeout
    },
    {
        "cmd": 'AT+HTTPHEAD',
        "match": 'AT\+HTTPHEAD\s{4}\+HTTPHEAD: \d+\s{2}(?:.|\n)*\s{4}OK\s{2}',
        "wait": b'OK',
        "timeout": wait_timeout
    },
    {
        "cmd": 'AT+HTTPSCONT',
        "match": 'AT\+HTTPSCONT\s{4}OK\s{2}',
        "wait": b'OK',
        "timeout": wait_timeout
    },
    {
        "cmd": 'AT+HTTPSCONT?',
        "match": 'AT\+HTTPSCONT\?\s{4}(?:.|\n)*OK\s{2}',
        "wait": b'OK',
        "timeout": wait_timeout
    },
    {
        "cmd": 'AT+HTTPTERM',
        "match": 'AT\+HTTPTERM\s{4}OK\s{2}',
    },
    {
        "cmd": 'AT+SAPBR=0,1',
        "match": 'AT\+SAPBR=0,1\s{4}OK\s{2}',
    },
]
